package com.easy.activiti;

import com.easy.activiti.ext.IActivitiCoreService;
import org.springframework.beans.BeansException;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;

/**
 * @author zhouchuang
 * 2024-10-31 18:44:18
 */


@Configuration
@ComponentScan(
        basePackages = {"com.easy.activiti"}
//        ,excludeFilters = {@ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, value = ProcessEngineAutoConfiguration.class)}
)
@ConditionalOnWebApplication
//@MapperScan("com.hfy.activiti.mapper")
public class ActivitiCoreAutoConfiguration implements ApplicationContextAware {

    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        try {
            applicationContext.getBean(IActivitiCoreService.class);
        } catch (BeansException e) {
            if(e.getMessage().contains("com.hfy.activiti.IActivitiCoreConfig")){
                throw new IllegalArgumentException("上层模块必须实现IActivitiCoreConfig");
            }else{
                throw e;
            }
        }
    }

}
